package com.starleague.battletech.unit.mech.jpa.appengine;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import com.starleague.battletech.unit.mech.IMechComponent;
import com.starleague.battletech.unit.mech.MechHitLocationPosition;

@Entity(name = "MECH_GYRO_CRITICAL_SLOT")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class MechGyroCriticalSlotGae
        extends MechCriticalSlotGae
{
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private MechGyroGae gyro;

    MechGyroCriticalSlotGae(MechGyroGae gyro,
                            MechHitLocationPosition position,
                            int index)
    {
        super(position, index);
        this.gyro = gyro;
    }

    protected MechGyroCriticalSlotGae()
    {
        //
    }

    @Transient
    @Override
    public IMechComponent getComponent()
    {
        return this.gyro;
    }

    @Override
    public String toStringSingleLine()
    {
        return "[" + this.gyro.getGyroType() + "] " + this.getId();
    }
}
